package com.sky.controller.user;

import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("userSetmealController")
@RequestMapping("user/setmeal")
@Slf4j
public class SetmealController {
    @Autowired
    private SetmealService setmealService;


    @GetMapping("page")
    public Result<PageResult> getPage(SetmealPageQueryDTO setmealPageQueryDTO){
       PageResult pageResult= setmealService.getPage(setmealPageQueryDTO);
       return Result.success(pageResult);
    }

    @GetMapping("{id}")
    public Result<SetmealVO> getById(@PathVariable Long id){
      SetmealVO setmealVO= setmealService.getById(id);
      return Result.success(setmealVO);
    }

    @GetMapping("list")
    public Result getListByCategoryId(Long categoryId){
        List<Setmeal> list= setmealService.getListBycategoryId(categoryId);
        return Result.success(list);
    }

}
